package main

import "fmt"

type Sample struct {
	Timestamp            int64
	Value                float64
}

func mergeSamples(a, b []Sample) []Sample {
	result := make([]Sample, 0, len(a)+len(b))
	i, j := 0, 0
	for i < len(a) && j < len(b) {
		if a[i].Timestamp < b[j].Timestamp {
			result = append(result, a[i])
			i++
		} else if a[i].Timestamp > b[j].Timestamp {
			result = append(result, b[j])
			j++
		} else {
			result = append(result, a[i])
			i++
			j++
		}
	}
	result = append(result, a[i:]...)
	result = append(result, b[j:]...)
	return result
}

func main(){
	a := []Sample{
		Sample{100, 1},
		Sample{101, 3},
		Sample{102, 5},
	}
	b := []Sample{
		Sample{100, 1},
		Sample{101, 3},
		Sample{103, 4},
	}

	fmt.Println(mergeSamples(a, b))
}